/**
 * TriangleMaking
 * 
 * difficuty: 250
 * 
 * Statement
You have three sticks. Their current lengths are a, b, and c. 
You can shorten each of those sticks arbitrarily. 
Your goal is to produce three sticks with the following properties:
1 The length of each stick is a positive integer.
2 The three sticks can be used to build a triangle. The triangle must be non-degenerate. (I.e., it must have a positive area.)
3 The perimeter of the triangle must be as large as possible.

You are given the ints a, b, and c. 
Compute and return the largest possible perimeter of the triangle constructed from your three sticks.

 * point:
 *   perimeter is a+b+c.
 *   ai + bi < ci
 *   
 *   just shorten the longest be  l < a+b
 *   and its done
 */
package org.yuwgle.srm.r697.d2;

import java.util.Arrays;

/**
 * The Class TriangleMaking.
 */
public class TriangleMaking {
	
	/**
	 * Max perimeter.
	 *
	 * @param a the a
	 * @param b the b
	 * @param c the c
	 * @return the int
	 */
	public int maxPerimeter(int a, int b, int c) {
		int[] nums = new int[]{a, b, c};
		Arrays.sort(nums);
		
		while (nums[0] + nums[1] <= nums[2]) {
			nums[2]--;
			Arrays.sort(nums);
		}
		
		return nums[0] + nums[1] + nums[2];
	}
	
	public static void main(String[] args) {
		TriangleMaking tm = new TriangleMaking();
		int ret;
		
		ret = tm.maxPerimeter(1, 2, 3);
		System.out.println(ret);
		
		ret = tm.maxPerimeter(2, 2, 2);
		System.out.println(ret);
		
		ret = tm.maxPerimeter(1, 100, 1);
		System.out.println(ret);
	}
}
